﻿using Microsoft.Phone.Net.NetworkInformation;

namespace Bango.WindowsPhone7_5.SDK
{
	internal class BangoStatic
	{
		internal static NetworkInterfaceInfo GetActiveNetworkInterfaceInfo()
		{
			NetworkInterfaceList netList = null;
			NetworkInterfaceInfo nInfo = null;

			if (NetworkInterface.GetIsNetworkAvailable())
			{
				netList = new NetworkInterfaceList();
				
				while (netList.MoveNext())
				{
					if (netList.Current.InterfaceState == ConnectState.Connected) 
					{
						nInfo = netList.Current;
						break;
					}
				}
			}

			return nInfo;
		}

		internal static string GetUserID()
		{
			return System.Convert.ToBase64String((System.Byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId"));
		}

		#region Device Information

		internal static System.String GetDeviceManufacturer()
		{
			return Microsoft.Phone.Info.DeviceStatus.DeviceManufacturer;
		}
		internal static System.String GetDeviceName()
		{
			return Microsoft.Phone.Info.DeviceStatus.DeviceName;
		}
		internal static System.String GetDeviceOSVersion()
		{
			return System.Environment.OSVersion.Version.ToString();
		}
		internal static System.String GetDeviceBuildID()
		{
			return Microsoft.Phone.Info.DeviceStatus.DeviceFirmwareVersion;
		}
		internal static System.String GetOperatorName()
		{
			return DeviceNetworkInformation.CellularMobileOperator;

		}

		/// <summary>
		/// Returns whether or not a network connection is available.
		/// </summary>
		/// <returns>Returns whether or not a network connection is available.</returns>
		internal static System.Boolean IsConnected()
		{
			return Microsoft.Phone.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
		}

		internal static System.String GetCountryCode()
		{
			return System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName;
		}

		#endregion

	}
}
